//
//  BusLineViewController.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/2.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "BusLineViewController.h"
#import "SegmentTapView.h"
#import "GuGuLandscapeTableView.h"
#import "AbleBusLineViewController.h"
#import "EnableBusLineViewController.h"
#import "StyleButton.h"
#import "UIButton+Dzm.h"
#import "StartCustomMadeViewController.h"
#import "PoisModel.h"

@interface BusLineViewController () <GuGuIndexDelegate,SegmentTapViewDelegate>
@property (nonatomic, strong)  SegmentTapView *segment;
@property (nonatomic , strong) GuGuLandscapeTableView *contentTable;
@property (nonatomic , strong) NSMutableArray *controllers;
@property (strong, nonatomic) IBOutlet UIButton *startCustonMadeBtn;

@end

@implementation BusLineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"班车路线";
    
    [self setLeftBtnItem];
    [self initSegmentTapView];
    [self initContentTableView];
    
    UIView *panView = [[UIView alloc ] initWithFrame:CGRectMake(0, 0, 30, 568)];
    panView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:panView];
    
    WEAKSELF
    [self.startCustonMadeBtn addActionHandler:^(UIButton *btn) {
        StartCustomMadeViewController*startCustomMade =   (StartCustomMadeViewController *)[StartCustomMadeViewController getViewControllerFromSbName:@"StartCustomMade" viewControllerName:@"StartCustomMadeViewController"];
        startCustomMade.title = @"发起定制";
        [weakSelf.navigationController pushViewController:startCustomMade animated:YES];
    }];
}


// 配置头部视图
-(void)initSegmentTapView{
    self.segment = [[SegmentTapView alloc] initWithFrame:CGRectMake(0, 0 , [UIScreen width] , 44)
                                           withDataArray:@[@"已开通",@"未开通"]];
    
    self.segment.delegate = self;
    self.segment.lineWidth = 60;
    [self.view addSubview:self.segment];
}

-(void)dealloc{
    self.contentTable.tableView.delegate = nil;
}

/**
 * segment点击回调
 * @param index
 */
-(void)selectedIndex:(NSInteger)index{
    [self.contentTable selectIndex:index];
}

-(void)initContentTableView
{
    self.controllers = [[NSMutableArray alloc ] init];
    [self initAbleBusLineViewController];
   [self initEnableBusLineViewController];
     self.contentTable = [[GuGuLandscapeTableView alloc]
                         initWithFrame:CGRectMake(0, 44, [UIScreen width], self.view.frame.size.height - 104-60)
                         Array:self.controllers];
    self.contentTable.swipeDelegate = self;
    [self.view addSubview:self.contentTable];
}


// 班车
-(void)initAbleBusLineViewController{
    
    AbleBusLineViewController *regularBusViewController = (AbleBusLineViewController *)[AbleBusLineViewController getViewControllerFromSbName:@"BuyTickets" viewControllerName:@"AbleBusLineViewController"];
    regularBusViewController.busLineViewController  = self;
    [self.controllers addObject:regularBusViewController];
}

// 直通车
-(void)initEnableBusLineViewController{
    EnableBusLineViewController *regularBusViewController = (EnableBusLineViewController *)[EnableBusLineViewController getViewControllerFromSbName:@"BuyTickets" viewControllerName:@"EnableBusLineViewController"];
    regularBusViewController.busLineViewController  = self;
    [self.controllers addObject:regularBusViewController];
}

-(void)barSelectedIndexChanged:(NSInteger)newIndex{
    [self.segment selectIndex:newIndex];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
